package com.googlecode.sere.method

import com.googlecode.sere.util.Logging
import com.googlecode.sere.translation.AcceptedTypes
import com.googlecode.sere.http.{Status, HttpRequest}
import com.googlecode.sere.core.{UrlRegistry, InvocationData}

class DeleteMethod(uri: String)
  extends RestMethod(uri, AcceptedTypes()) with Logging {

  def process(meta: InvocationData) = {
    val (resourceType, id) = UrlRegistry.matchUrl(uri)
    resourceType.delete(id, meta)
    EmptyResponse(Status.Ok)
  }
}

object DeleteMethod {
  def fromRequest(request: HttpRequest) = new DeleteMethod(request.uri)
}